#ifndef	_JOB_H_
#define _JOB_H_

#include "common.h"
#include <iostream>
#include "Globals.h"
#include "Match.h"
#include "DiagStretch.h"

///#include <tbb/task.h>

/* types of job */
#define DIAGS_JOB			1
#define FILE_READ		 	2
#define RESULT_SORT	3

class Job///: public tbb::task
{
  private:
  	/* The type of job to be executed */
  	uint type;
  	
  	bool done;
  	
  	/* Place of the input file in input files order */ 
  	uint inputFileIndx;
  	/* Place of the sequence in sequences order of an input file */ 
  	uint seqInFile;
  	/* A vector that will hold the results of this processing job */
	vector<Match> matches;
	/* Array of digonal stretches to process */
	DiagStretch *diags;

	void processDiags();
	
	void readFile();
	
	void sortJobs();
	
  public:
	Job(uint type, uint inputFileIndx, uint seqInFile = -1, DiagStretch *diags = NULL);

	~Job();
	
	inline uint getType() const;
	
	inline uint getInputFileIndx() const;
	
	inline uint getSeqInFile() const;
	
	inline const vector<Match>& getMatches() const;
	
	void process();
	///task* execute();

	
};

/* this is temporary solution for storing and sorting the results */
extern vector< vector<Job*> >  *myDoneJobs;

/* Moved these methods here, to allow inline */
inline uint Job::getType() const
{
	return type;
}

inline uint Job::getInputFileIndx() const
{
    return inputFileIndx;
}

inline uint Job::getSeqInFile() const
{
    return seqInFile;
}

inline const vector<Match>& Job::getMatches() const
{
    return matches;
}


#endif /* _JOB_H_ */
